package com.whynot.frame.manythread.producerandcusumer.comsume;

import java.util.concurrent.BlockingDeque;

import com.whynot.frame.manythread.producerandcusumer.entities.Data;

public class Comsume implements Runnable{
	private BlockingDeque<Data> qeque ;
	
	
	public Comsume(BlockingDeque<Data> qeque) {
		super();
		this.qeque = qeque;
	}


	public void run() {
		System.out.println("消费者的当前线程Id:"+Thread.currentThread().getId());
		try {
			while(true){
				Data data = qeque.take();//take 如果取不到数据，那么返回null
				if( null != data){
					System.out.println("获取的数据:"+data);
						Thread.sleep(1000);
				}
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
			Thread.currentThread().interrupt();
		}
	}

}
